package com.twu.biblioteca;

import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class MainMenu {

    private final InputStream inputStream;

    public MainMenu(InputStream inputStream) {
        this.inputStream = inputStream;
    }

    public int mainMenuLauncher() throws NoSuchElementException {
        int userSelection;
        Scanner userInput = new Scanner(this.inputStream);
        System.out.println("++++++++++++ Main Menu +++++++++++++++");
        System.out.println("        1: Book List");
        System.out.println("        2: Movie List");
        System.out.println("        3: Checkout Book or Movie");
        System.out.println("        4: Return Book or Movie");
        System.out.println("        5: Show my User Information");
        System.out.println("        9: Quit");
        System.out.println("++++++++++++++++++++++++++++++++++++++");
        System.out.println("Choose your Option: ");
        String temp = userInput.nextLine();
        userSelection = Integer.parseInt(temp);

        return userSelection;
    }

    public int recordCheckout() throws IndexOutOfBoundsException {
        int bookId;
        Scanner userInput = new Scanner(this.inputStream);
        System.out.println("Please enter the Id of the item you want to check out: ");
        String temp = userInput.nextLine();
        bookId = Integer.parseInt(temp);
        return bookId;
    }

    public int returnRecord() {
        int bookNumber;
        Scanner userInput = new Scanner(this.inputStream);
        System.out.println("Please enter the Id of the item you want to return: ");
        String number = userInput.nextLine();
        bookNumber = Integer.parseInt(number);

        return bookNumber;
    }
}
